package com.chejianer.push.utils;
import com.corundumstudio.socketio.SocketIOServer;
import lombok.extern.slf4j.Slf4j;

/**
 * Socketio的线程工具类
 */
@Slf4j
public class SocketThreadUtil extends Thread{

    public static SocketIOServer socketIOServer;

    public static void startSocketThread(){
        SocketThreadUtil thread=new SocketThreadUtil();
        thread.start();
    }
    public void run(){
        try{
            socketIOServer.startAsync();
            log.info("socketio server started");
        }catch(Exception e){
            log.error("socketio server failed to start,see this message:",e.getMessage());
        }

    }

    public static void closeSocketIOServer(){
        if(socketIOServer!=null){
            socketIOServer.stop();
            log.info("socketio stopped");
        }
    }
}
